package game.block.command;

import game.block.Constants;
import game.block.entity.MovableEntity;
import game.block.tile.Tile;

public class MoveCommand extends Command implements Constants{

    private MovableEntity block;
    private Tile tile;
    private Tile prevTile;
    
    public MoveCommand(MovableEntity block, Tile tile, Tile prevTile){
        this.block=block;
        this.prevTile=prevTile;
        this.tile=tile;
    }
    
    @Override
    public void execute() {
        block.moveTo(tile,TURN_LENGTH);
        block.getCurrentTile().changeColor(COLOR.BLANK);
        block.setCurrentTile(tile);
        tile.add(block);
        prevTile.remove(block);
    }

    @Override
    public void undo() {
        block.moveTo(prevTile,0.1f);
        block.getCurrentTile().changeColor(COLOR.BLANK);
        block.setCurrentTile(prevTile);
        tile.remove(block);
        prevTile.add(block);
    }

}
